package com.jt.tenant.conn;

import com.jt.tenant.app.JTApplication;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 诊断报告
 */
@HttpInlet(Conn.INLET_GET_DTCLIST_BY_ID)
public class GetFaultListById extends JTAsyGet<List<GetFaultListById.Info>> {

    public String token = JTApplication.jtPreferences.readToken();

    public String id;

    public GetFaultListById(AsyCallBack<List<Info>> asyCallBack) {
        super(asyCallBack);
    }


    @Override
    protected List<Info> parserBody(Object body) {

        List<Info> list = new ArrayList<>();

        JSONArray array = ((JSONObject) body).optJSONArray("detailList");

        if (array != null) {

            for (int i = 0; i < array.length(); i++) {

                JSONObject object1 = array.optJSONObject(i);

                Info info = new Info();

                info.id = object1.optString("id");

                info.descrption = object1.optString("descrption");

                info.suggest = object1.optString("suggest");

                info.code = object1.optString("code");

                list.add(info);
            }
        }

        return list;

    }

    public static class Info implements Serializable {

        public String id, descrption,suggest,code;

    }

}
